class Person {
  // 静态属性，用于存储唯一实例
  static instance = null;
  name: string;
  age: number;
  constructor(name?, age?) {
    if (Person.instance) {
      return Person.instance;
    }
    Person.instance = this;
    this.name = name;
    this.age = age;
  }

  // 静态方法，用于获取唯一实例
  static getInstance(name?: string, age?: number): Person {
    if (!Person.instance) {
      Person.instance = new Person();
    }
    return Person.instance;
  }

  setInfo(name: string, age: number) {
    this.name = name;
    this.age = age;
  }

  getInfo(): string {
    return "姓名：" + this.name + "，年龄：" + this.age;
  }
}

export default Person;
